home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / mxlibs / dwstk102 / findsb.c < prev    next >
C/C++ Source or Header  |  1995-04-12  |  3KB  |  102 lines

  1. /******************************************************************************
  2. File:          findsb.c
  3. Version:     1.02
  4. Tab stops: every 2 columns
  5. Project:     FINDSB utility
  6. Copyright: 1994-1995 DiamondWare, Ltd.    All rights reserved.
  7. Written:     Keith Weiner & Erik Lorenzen
  8. Purpose:     Example code to autodetect and print out the sound hardware
  9. History:     94/10/21 KW        Started
  10.                      95/02/01 KW/EL Finalized
  11.                      95/03/22 EL        Finalized for 1.01
  12.                      95/04/11 EL        Finalized for 1.02
  13. ******************************************************************************/
  14.  
  15.  
  16.  
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19.  
  20. #include "dws.h"
  21. #include "err.h"
  22.  
  23.  
  24.  
  25. void main(void)
  26. {
  27.     dws_DETECTOVERRIDES dov;
  28.     dws_DETECTRESULTS     dres;
  29.  
  30.     printf("\nFINDSB 1.02 is Copyright 1994-95 DiamondWare, Ltd.\n");
  31.     printf("All rights reserved.\n\n\n");
  32.  
  33.     /*
  34.      . We need to set every field to -1 in dws_DETECTOVERRIDES struct;
  35.      . this tells the STK to autodetect everything.  Any other value
  36.      . overrides the autodetect routine, and will be accepted on
  37.      . faith, though the STK will verify it if possible.
  38.     */
  39.     dov.baseport = (word)-1;
  40.     dov.digdma     = (word)-1;
  41.     dov.digirq     = (word)-1;
  42.  
  43.     if (!dws_DetectHardWare(&dov, &dres))
  44.     {
  45.         err_Display(dws_ErrNo());
  46.         exit(-1);
  47.     }
  48.  
  49.     /* Test for FM or DIG */
  50.     if ((dres.capability & dws_capability_FM) ||
  51.             ((dres.baseport != 0x388) && (dres.baseport != (word)-1)))
  52.     {
  53.         printf("Base port is %x hex.\n\n", dres.baseport);
  54.  
  55.         if (dres.mixtyp > 1)
  56.         {
  57.             printf("The sound hardware supports mixing.\n\n");
  58.         }
  59.         else
  60.         {
  61.             printf("Mixing will be done in software.\n\n");
  62.         }
  63.  
  64.         if (dres.capability & dws_capability_FM)
  65.         {
  66.             printf("The sound hardware supports FM music playback.\n\n");
  67.         }
  68.         else
  69.         {
  70.             printf("Support for FM music playback not found.\n\n");
  71.         }
  72.  
  73.         if (dres.capability & dws_capability_DIG)
  74.         {
  75.             /* If we got here dws_DetectHardWare got PORT, IRQ, & DMA */
  76.             printf("The sound hardware supports digitized sound playback.\n\n");
  77.             printf("The sound hardware uses DMA channel %d and IRQ level %d.\n\n",
  78.                          dres.digdma, dres.digirq);
  79.         }
  80.         else if ((dres.baseport != 0x388) && (dres.baseport != (word)-1))
  81.         {
  82.             /*
  83.              . If dres.baseport isn't either 388hex, or -1, then it's a valid
  84.              . baseport.    So if we got here, then we didn't find either IRQ
  85.              . level, and/or DMA channel.  In order to play digitized sounds,
  86.              . we need these settings as well.    In your application, you should
  87.              . ask the user.
  88.             */
  89.             printf("The sound hardware supports digitized sound playback,\n");
  90.             printf("but we couldn't find the DMA channel and/or IRQ level.\n\n");
  91.         }
  92.         else
  93.         {
  94.             printf("Support for digitized playback not found.\n\n");
  95.         }
  96.     }
  97.     else
  98.     {
  99.         printf("No sound hardware detected.\n\n");
  100.     }
  101. }
  102.